// https://nuxt.com/docs/api/configuration/nuxt-config
import { defineNuxtConfig } from 'nuxt/config'

export default defineNuxtConfig({
  compatibilityDate: '2025-05-15',
  devtools: { enabled: true },
  modules: ['@nuxtjs/tailwindcss', '@nuxtjs/i18n', '@nuxt/icon'],
  plugins: [
    '~/plugins/aos.client.ts'
  ],
  i18n: {
    defaultLocale: 'zh',
    langDir: 'locales/',
    locales: [
      { code: 'en', name: 'English', file: 'en.json' },
      { code: 'zh', name: '中文', file: 'zh.json' }
    ]
  },
  devServer: {
    host: '0.0.0.0',
    port: 3000
  },
  icon: {
    provider: 'server',
    customCollections: [
      {
        prefix: 'svg',
        dir: './assets/svg'
      },
    ]
  },
  app:{
    head: {
      // no-index
      meta: [
        { name: 'robots', content: 'no-index' },
      ],
      script: [
        {
          innerHTML: `
            (function() {
              try {
                const savedMode = localStorage.getItem('color-mode');
                const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
                
                if (savedMode === 'dark' || (!savedMode && prefersDark)) {
                  document.documentElement.classList.add('dark');
                }
              } catch (e) {
                console.error('Error applying dark mode on initial load:', e);
              }
            })();
          `,
          type: 'text/javascript'
        }
      ],
    }
  },
  ssr: true
})